package ryanbrown.android.helloandroid;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

import android.app.Activity;
import android.net.Proxy;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        try {
        	String result = "";
        	Enumeration<NetworkInterface> netAddresses = NetworkInterface.getNetworkInterfaces();
        	while(netAddresses.hasMoreElements()) {
        		NetworkInterface n = netAddresses.nextElement();
        		Enumeration<InetAddress> netAddresses2 = n.getInetAddresses();
        		while(netAddresses2.hasMoreElements()) {
        			result += netAddresses2.nextElement().getHostAddress();
        		}
        	}
        	result += "" + Proxy.getDefaultHost() + Proxy.getDefaultPort();

        	((TextView)findViewById(R.id.helloText)).setText(result);
        } catch (Exception e) {
        	((TextView)findViewById(R.id.helloText)).setText(e.getMessage()+ Proxy.getDefaultHost() + Proxy.getDefaultPort());
        }
    }
}